<?php include $this->admin_tpl('meta');?>
<title>稿件管理 - YzmCMS内容管理系统</title>
</head>
<body>
<nav class="breadcrumb"><i class="yzm-iconfont yzm-iconai-home"></i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 稿件管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="yzm-iconfont yzm-iconshuaxin"></i></a></nav>
<div class="page-container">
	<div> 
	<form action="<?php echo U('init');?>" method="get" id="search">
	 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
	 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
	 <input type="hidden" value="init" name="a">
	 <span class="select-box inline">
		<select name="modelid" class="select">
			<option value="0">所有模型</option>
			<?php 
				foreach($modelinfo as $val){
					$str = $val['modelid']==$modelid ? 'selected' : '';
					echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
				}
			?>
		</select>
	</span>
	 <span class="select-box inline"><?php echo select_category('catid', $catid, '内容分类', 0, '', true, true, $modelid); ?></span>
	 更新时间：<input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start'] != '') echo 'value="'.$_GET['start'].'"'; ?>>
     至 <input type="text" class="input-text laydate-icon" style="width:170px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end'] != '') echo $_GET['end']; else echo date('Y-m-d H:i:s'); ?>">
	 <span class="select-box inline">
		<select name="status" class="select">
	    <option value="99">状态</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='0'){echo 'selected';} ?> value="0">未审核</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='1'){echo 'selected';} ?> value="1">已通过</option>
		<option <?php if(isset($_GET["status"]) && $_GET["status"]=='2'){echo 'selected';} ?> value="2">已退稿</option>
		</select>
	</span>
	<span class="select-box inline">
		<select name="type" class="select">
	    <option <?php if(isset($_GET["type"]) && $_GET["type"]=='1'){echo 'selected';} ?> value="1">内容标题</option>
			<option <?php if(isset($_GET["type"]) && $_GET["type"]=='2'){echo 'selected';} ?> value="2">稿件ID</option>	
			<option <?php if(isset($_GET["type"]) && $_GET["type"]=='3'){echo 'selected';} ?> value="3">发布人</option>	
		</select>
	</span>
	 <input type="text" name="searinfo" class="input-text search" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>"><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
	 <a href="<?php echo U('init');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
	 </form>	
	</div>
	<div class="cl mt-15 tb-top"> <span class="l"><a href="javascript:;" onclick="adopt()" class="btn btn-primary radius"><i class="yzm-iconfont yzm-icontongguo"></i> 通过审核</a> <a href="javascript:;" onclick="yzm_dels('ids', 1)" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a> <a href="javascript:;" onclick="show_rejection()" class="btn btn-warning radius"><i class="yzm-iconfont yzm-iconshanchu"></i> 退稿</a></span> <span class="r">共有数据：<strong><?php echo $total?></strong> 条</span> </div>
  <form method="post" action="<?php echo U('del');?>" id="myform">
  <table class="table table-border table-bg table-hover yzm-table-sort">
    <thead>
      <tr class="text-c">
        <th width="25"><input type="checkbox"></th>
		<th width="50">稿件ID</th>
		<th>标题</th>
		<th width="120">发布人<?php echo field_order('userid');?></th>
		<th width="135">更新时间<?php echo field_order('updatetime');?></th>
		<th width="110">内容分类<?php echo field_order('catid');?></th>
		<th width="70">所属模型</th>
		<th width="60">状态<?php echo field_order('status');?></th>
		<th width="60">管理操作</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" value="<?php echo $val['allid']?>" name="ids[]"></td>
			<td><?php echo $val['allid'];?></td>
			<td class="text-l">
			<?php
			if($val['thumb']){
			 echo '<span style="color:#0a6999;font-size:14px;vertical-align:middle;" onmouseover="yzm_img_browse(this, \''.$val['thumb'].'\')" onmouseout="layer.closeAll(\'tips\')" class="yzm-iconfont yzm-icontupian1 pointer"></span>';
			}
			?>	
			<a href="<?php echo U('public_preview', array('catid'=>$val['catid'], 'id'=>$val['id']));?>" target="_blank" ><?php echo $val['title'];?></a>	
			</td>
			<td><?php echo $val['username'];?></td>
			<td><span title="<?php echo '发布时间：'.date('Y-m-d H:i:s', $val['inputtime'])."\r\n更新时间：".date('Y-m-d H:i:s', $val['updatetime'])?>"><?php echo date('Y-m-d H:i:s', $val['updatetime'])?></span></td>
			<td><?php echo get_catname($val['catid']);?></td>
			<td><?php echo get_model($val['modelid'], 'name')?></td>
			<td><?php echo $val['status']=='0' ? '<span class="label radius">未审核</span>' : ($val['status']=='1' ? '<span class="label label-success radius">已通过</span>' :'<span class="label label-danger radius">已退稿</span>');?></td>
			<td>
				<a title="编辑" href="javascript:;" onclick="yzm_open_full('编辑内容','<?php echo U('admin/content/edit',array('modelid'=>$val['modelid'],'id'=>$val['id']));?>')" class="ml-5" style="text-decoration:none"><i class="yzm-iconfont yzm-iconbianji2"></i></a> 
				<a title="预览" href="<?php echo U('public_preview', array('catid'=>$val['catid'], 'id'=>$val['id']));?>" class="ml-5" target="_blank" style="text-decoration:none"><i class="yzm-iconfont yzm-iconyulan2"></i></a>
			</td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
  </form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>

<div id="rejection_mess" style="margin:10px 15px 0 15px;display:none">
	<textarea name="content_c" class="textarea" style="width:400px;margin-bottom:5px" placeholder="请输入退稿原因，退稿原因将会以短消息方式发送！"></textarea>
	<select class="select" style="width:170px;height:30px;line-height:30px;display:block;" onchange="change_rejection(this.value)">
		<option value="">= 快速选择退稿原因 =</option>
		<option value="不符合投稿格式要求：请注意正文前后署名格式。">不符合投稿格式要求</option>
		<option value="稿件标题重复或雷同：请根据内容编辑贴切具体的标题。">稿件标题重复或雷同</option>
		<option value="稿件内容重复：可能与自己发表或同学已发表稿件内容重复，不要投递重复内容。">稿件内容重复</option>
		<option value="图片无法显示：请将图片上传到本站，不可引用外站图片，图片宽度不可超过800像素。">图片无法显示</option>
		<option value="内容过于草率：请丰富稿件正文内容，插入对应图片（不可重复插入已在其他稿件出现过的图片）。">内容过于草率</option>
		<option value="含有较多敏感信息：内容涵盖较多国家党政敏感信息，不适合在我站展示。">含有较多敏感信息</option>
		<option value="含有编程代码：对网站展示有一定风险或错觉。">含有编程代码</option>
		<option value="内容中含有广告推广或其他联系方式。">含有广告推广</option>
	</select>
</div>

<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">
	//通过审核
	function adopt(){
		if ($("input[name='ids[]']:checked").length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}	
	    $.ajax({
			type: "POST",
			url: "<?php echo U('admin_content/adopt');?>", 
			data: $("#myform").serialize(),
			dataType: "json", 
			success: function (msg) {
				layer.msg(msg.message, {icon:1, time:1000}, function(){
					location.reload();
				});
			}
	   })	
	}

	//退稿
	function show_rejection() {
		if ($("input[name='ids[]']:checked").length<1){
		   layer.alert('请选择要操作的内容！');
		   return false;
		}
		layer.open({
			type: 1,
			title: '内容退稿',
			btn: ['发送', '取消'],
			content: $('#rejection_mess'),
			yes: function(index, layero){
				var content_c = $("textarea[name='content_c']").val();
				if(content_c == ''){
					layer.msg("请输入退稿原因！", {icon:2,time:2000});
					return false;
				}
			    $.ajax({
	               type: "POST",
	               url: "<?php echo U('admin_content/rejection');?>", 
	               data: $("#myform").serialize()+'&content_c='+content_c,
	   		       dataType: "json", 
	               success: function (msg) {
	   					if(msg.status == 1){
	   						layer.msg(msg.message, {icon:1, time:1000}, function(){
	   							location.reload();
	   						});
	   				    }else{
	   						layer.msg(msg.message, {icon:2});
	   					}
	               }
	           })
			}
		});
	}

	function change_rejection(val) {
		$("textarea[name='content_c']").val(val);
	}

	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);
</script>

</body>
</html>